<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>高级搜索</title>
</head>
<body>
<div class="hbox hbox-auto-xs hbox-auto-sm"  >
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row" style=" padding-right: 15px; ">
                <div class="col-sm-6 col-xs-12">
                    <span class="h3" >高级搜索</span>
                </div>
            </div>
        </div>

        <div class="wrapper-md paddingbottomNone">
            <div class="panel panel-default" style="padding-bottom: 10px;">
                <div style="margin-left:10px;line-height:50px;">  <button type="button" class="btn btn-primary" ng-click="addTableCondition()" >添加查询模块</button> &nbsp;&nbsp; <button type="button" class="btn btn-success" ng-click="saveSqlSubmit()" >查询</button> &nbsp;&nbsp; <button type="button" class="btn btn-danger " ng-click="clearCondition()" >清空查询模块</button> &nbsp;&nbsp;</div>

                <div class="table-responsive">
                    <table class="table table-striped m-b-none"   style="border:1px solid #e0e3ee;margin-top:10px;width:98%;margin-left:1%;margin-right:1%;"    ng-repeat="dataList in logicalCondition" >
                        <thead>

                            <tr style="border-bottom:0px !important;">
                                <td><select ng-model="dataList.andOr" style="border-radius: 4px; " ng-if="logicalCondition.length > 1 && $index!=0"><option value="UNION" selected = "selected">并且</option><option value="UNION ALL">或者</option></select> </td>
                                <td> </td>
                                <td> </td>
                                <td> </td>
                                <td  style="border-bottom:0px !important;"> <button type="button" class="btn btn-primary" ng-click="addParentRow(tableMark)" >添加查询条件</button> <button type="button" class="btn btn-danger "  ng-click="removeParentTable(tableMark)" >删除查询模块</button>&nbsp;&nbsp;</td>

                            </tr>
                            <tr style=" border-top:0px !important;">
                                <td  style=" border-top:0px !important;"> 字段</td>
                                <td style=" border-top:0px !important;">匹配类型</td>
                                <td style=" border-top:0px !important;">取值</td>
                                <td style=" border-top:0px !important;">逻辑</td>
                                <td style=" border-top:0px !important;">操作</td>
                            </tr>
                            <tr ng-bind="tableMark=$index" style="display:none"></tr>
                        </thead>
                        <tbody>

                         <tr  ng-repeat="data in dataList.table"  style="border:1px solid #e0e3ee;"   >
                             <td><select ng-model="data.field" ng-change="typeChange(data.field,$index,tableMark)"    ng-options="dm.paramCode as dm.paramName for dm in knowledgeMapping" > <option   value="">请选择</option><!--<option ng-repeat="dm in knowledgeMapping"  value="{{dm.paramCode}}">{{dm.paramName}}</option>--></select></td>
                             <td>

                                 <select ng-model="data.mappingType"  ng-show="data.type!='子表' &&  data.field!='materialTrait'">
                                     <option    value="">请选择</option>
                                     <option    value="like" ng-if="data.type!='下拉框'">包含</option><option value="not like" ng-if="data.type!='下拉框'">不包含</option><option value="=" ng-if="data.type!='下拉框'">等于</option><option value="!=" ng-if="data.type!='下拉框'">不等于</option>
                                     <option    value="like" ng-if="data.type=='下拉框'">选中</option><option value="not like" ng-if="data.type=='下拉框'">反选</option>
                                 </select>

                             </td>

                             <td>
                              <div ng-if="data.type=='文本框'">
                                  <input ng-model="data.fieldValue" >
                              </div>
                             <div ng-if="data.type=='下拉框'">

                                <select ng-model="data.fieldValue"     >
                                    <!--ng-options="vopt.code as vopt.name for vopt in dataRepository[data.field]"-->
                                    <option value="{{data.fieldValue}}"  ng-if="data.fieldValue==''"  value="">请选择</option>
                                    <option value="{{data.fieldValue}}"  ng-if="data.fieldValue!=''" >{{data.fieldValue}}</option>
                                    <option ng-repeat="vopt in dataRepository[data.field]" value="{{vopt.code}}">{{vopt.name}}</option>
                                </select>
                             </div>
                             <div ng-if="data.type=='范围框'">
                                     <input style="width:45%" type="number" ng-model="data.minValue"/>~<input  style="width:45%" type="number" ng-model="data.maxValue">
                             </div>
                             </td>
                             <td><select ng-model="data.logic"  ng-if="$index!=0"><option value="">请选择</option><option value="and">并且</option><option value="or">或者</option></select></td>
                             <td><button type="button" class="btn btn-danger "  ng-click="removeParentRow($index,tableMark)" >删除查询条件</button></td>
                         </tr>
                            <tr  ng-if= " dl.field == 'materialTrait'"  ng-repeat="dl in dataList.table" >

                                    <td    colspan="5">
                                    <table class="table table-striped m-b-none"     style=" width:80%;  border:1px solid #e0e3ee;  ">
                                        <thead>
                                        <tr>
                                            <td> </td>
                                            <td> </td>
                                            <td> </td>
                                            <td> </td>
                                            <td><button type="button" class="btn btn-primary" ng-click="addChildRow(tableMark,$index)">添加材料特点条件</button>  </td></td>
                                        </tr>
                                        <tr>
                                            <td style=" border-top:0px !important;">字段 </td>
                                            <td style=" border-top:0px !important;">匹配类型</td>
                                            <td style=" border-top:0px !important;">取值</td>
                                            <td style=" border-top:0px !important;">逻辑</td>
                                            <td style=" border-top:0px !important;">操作</td>
                                        </tr>
                                        <tr ng-bind="tableChildMark=$index" style="display:none"></tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="dataC in dl.child" style="border:1px solid #e0e3ee;">
                                            <td><select ng-model="dataC.field" ng-change="typeChildChange(dataC.field ,$index,tableMark,tableChildMark)" ><option value="{{dataC.field}}" ng-if="dataC.field==''">请选择</option><option value="{{dataC.field}}" ng-if="dataC.field!=''">{{dataC.field}}</option> <option ng-repeat="dm in knowledgeChildMapping"  value="{{dm.paramName}}">{{dm.paramName}}</option> </select></td>
                                            <td>

                                                    <select ng-model="dataC.mappingType">
                                                        <option value="">请选择</option>
                                                        <option value="like" >包含</option>
                                                        <option value="not like"  >不包含</option>
                                                    </select>

                                            </td>
                                            <td>
                                                <div ng-if="dataC.type=='文本框'">
                                                    <input ng-model="dataC.fieldValue" >
                                                </div>
                                                <div ng-if="dataC.type=='下拉框'">

                                                    <select ng-model="dataC.fieldValue"  >
                                                        <option value=""  >请选择</option>

                                                    </select>
                                                </div>
                                                <div ng-if="dataC.type=='范围框'">
                                                    <input  style="width:45%" type="number" ng-model="dataC.minValue"/>~<input style="width:45%" type="number" ng-model="dataC.maxValue">
                                                </div>

                                            </td>
                                            <td><select ng-model="dataC.logic" ng-if="$index!=0"><option value="">请选择</option><option value="and">并且</option><option value="or">或者</option></select></td>
                                            <td><button type="button" class="btn btn-danger " ng-click="removeChildRow($index,tableMark,tableChildMark)" >删除查询条件</button></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </td>

                            </tr>


                        </tbody>

                    </table>
                </div>
            </div>
        </div>

    </div>
</div>



</body>
</html>